<template>
  <div class="container">
    <div class="backgroundImg">
      <div class="welcome">Hi！欢迎</div>
      <div class="userName">用户: {{ userName || '' }}</div>
    </div>
    <div class="navigatorList">
      <div class="navigatorItem" @click="$router.push('/homeWorkList')">
        <div class="leftImg"></div>
        <div class="middleInfo">
          <div class="infoTitle">作业票信息</div>
          <div class="infoDes">作业票列表,可查看审核状态与开锁</div>
        </div>
        <div class="rightImg">
          <div class="numDot">{{ indexData.allNum }}</div>
          <img src="@/assets/组 5407.png" alt="" />
        </div>          
      </div>
      <div class="navigatorItem" @click="$router.push('/examineHomework')">
        <div class="leftImg leftImg2"></div>
        <div class="middleInfo">
          <div class="infoTitle">待我审批</div>
          <div class="infoDes">推送待审核作业票，待您审批</div>
        </div>
        <div class="rightImg">
          <div class="numDot">{{ indexData.myNum }}</div>
          <img src="@/assets/组 5407.png" alt="" />
        </div>
      </div>
    </div>
    <div class="applyHomeWork" @click="goAddHomeWork">
      <img src="@/assets/组 5410.png" alt="" class="addPic" />
      <div>申请有限空间安全作业票</div>
    </div>
  </div>
</template>

<script>
import { homePageApi } from '@/api/index'
export default {
  name: 'indexPage',
  props: {},
  components: {},
  data() {
    return {
      indexData: {},
      userName: JSON.parse(sessionStorage.getItem('loginInfo'))?.userName,
    }
  },
  created() {
    this.homePage()
  },
  methods: {
    goAddHomeWork() {
      this.$router.push('/addHomeWork')
    },
    async homePage() {
      const res = await homePageApi({
        id: JSON.parse(sessionStorage.getItem('loginInfo'))?.userId,
      })
      this.indexData = res.data
      // console.log(res)
    },
  },
  mounted() {},
  watch: {},
  computed: {},
  filters: {},
}
</script>

<style scoped lang="scss">
.backgroundImg {
  width: 100%;
  height: 240px;
  background-image: url('@/assets/组 5806.png');
  background-repeat: no-repeat;
  background-size: cover;
  .welcome {
    font-size: 24px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #ffffff;
    line-height: 33px;
    padding-top: 80px;
    margin-left: 40px;
  }
  .userName {
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #ffffff;
    line-height: 22px;
    margin-top: 10px;
    margin-left: 40px;
  }
}
.navigatorList {
  padding: 0 16px;
  .navigatorItem {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: #ffffff;
    box-shadow: 0px 1px 3px 1px rgba(0, 12, 27, 0.08);
    border-radius: 8px;
    // width: 343px;
    height: 80px;
    margin-bottom: 16px;
    transform: translateY(-50px);
    .leftImg {
      background-image: url('@/assets/2.png');
      width: 48px;
      height: 48px;
      background-repeat: no-repeat;
      background-size: cover;
    }
    .leftImg2 {
      background-image: url('@/assets/1.png');
    }
    .middleInfo {
      margin-left: 10px;
      .infoTitle {
        font-size: 16px;
        font-family: PingFang SC;
        font-weight: 800;
        color: #333333;
        line-height: 22px;
      }
      .infoDes {
        font-size: 12px;
        color: #6a6c6f;
        margin-top: 12px;
      }
    }
    .rightImg {
      display: flex;
      align-items: center;
      .numDot {
        width: 24px;
        height: 24px;
        background: #ef0000;
        border-radius: 50%;
        text-align: center;
        line-height: 24px;
        color: #ffffff;
        font-size: 12px;
        font-weight: bold;
      }
    }
  }
}
.applyHomeWork {
  width: 343px;
  height: 48px;
  background: linear-gradient(270deg, #0066f1 0%, #3783ff 100%);
  box-shadow: 0px 3px 6px 1px rgba(8, 25, 42, 0.08);
  border-radius: 24px;
  color: #ffffff;
  line-height: 48px;
  text-align: center;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  .addPic {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }
}
</style>
